import { createRouter, createWebHistory } from 'vue-router'

// views
// import MainIndex from '@/views/mainIndex.vue'
// import LoginIndex from '@/views/loginIndex.vue'
// import WorkBench from '@/views/workBench.vue'
// import UserInfo from '@/views/userInfo.vue'
// import editData from '@/views/editData.vue'

const router = createRouter({
  history: createWebHistory('/'),
  routes: [
    {
      path: '/',
      name: 'login',
      component: () => import('@/views/loginIndex.vue')
    },
    {
      path: '/index',
      component: () => import('@/views/mainIndex.vue'),
      children: [
        {
          path: '/index',
          name: 'index',
          components: {
            content: () => import('@/components/index/contentMain.vue')
          },
          redirect: (to) => {
            return { name: 'card' }
          },
          children: [
            {
              path: '/',
              redirect: (to) => {
                return { name: 'card' }
              }
            },
            {
              path: 'card/:key?',
              name: 'card',
              components: {
                center: () => import('@/components/index/card/cardIndex.vue')
              }
            },
            {
              path: 'columns/:key?',
              name: 'columns',
              components: {
                center: () => import('@/components/index/columns/columnsIndex.vue')
              }
            },
            {
              path: 'followig',
              name: 'followig',
              components: {
                center: () => import('@/components/index/followig/followigIndex.vue')
              }
            },
            {
              path: 'msg',
              name: 'msg',
              components: {
                left: () => import('@/components/index/message/msgUsers.vue'),
                center: () => import('@/components/index/message/msgIndex.vue'),
                right: () => import('@/components/imgToUrl.vue')
              }
            },
            {
              path: 'history',
              name: 'history',
              components: {
                center: () => import('@/components/index/history/historyIndex.vue')
              }
            },
            {
              path: 'art/:id?',
              name: 'art',
              components: {
                center: () => import('@/components/index/artical/artView.vue')
              }
            },
            {
              path: 'result/:key?',
              name: 'searchResult',
              components: {
                center: () => import('@/components/index/searchResult.vue')
              }
            }
          ]
        },
        {
          path: 'edit/:id?',
          name: 'edit',
          components: {
            title: () => import('@/components/index/indexTitle.vue'),
            content: () => import('@/views/editData.vue')
          }
        },
        {
          path: 'info/:key?',
          name: 'info',
          components: {
            title: () => import('@/components/index/indexTitle.vue'),
            content: () => import('@/views/userInfo.vue')
          }
        }
      ]
    },

    {
      path: '/work/:id?',
      name: 'work',
      component: () => import('@/views/workBench.vue')
    },
    {
      path: '/infoCard',
      component: () => import('@/components/popUps/showInfo.vue')
    }
  ]
})

// router.beforeEach((to, from, next) => {
//   console.log('即将进入:', to)
//   console.log('当前路由:', from)
//   next()
// })
export default router
